﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ObligatorioBD
{
    public partial class frmDatabaseName : Form
    {
        string databaseName;
        public frmDatabaseName()
        {
            InitializeComponent();
        }
        public string DatabaseName
        {
            get { return this.databaseName; }
        }
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                this.databaseName = txtDatabaseName.Text;
                if (this.databaseName.Contains(" "))
                {
                    throw new Exception("El nombre de la base no puede contener espacios en blanco");
                }
                char primer = this.databaseName[0];
                int i;
                if (int.TryParse(primer.ToString(),out i))
                {
                    throw new Exception("El nombre de la base no puede comenzar con un número");
                }

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Nombre incorrecto", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}
